<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="java.util.*" %>
<%@ include file="/page/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<%@ include file="/adapter/adapter-bootstrap.jsp" %>


<script type="text/javascript">
var tempid="";
var patrn=/[\u4E00-\u9FA5]|[\uFE30-\uFFA0]/gi;
var containSpecial = RegExp(/[(\ )(\~)(\!)(\@)(\#) (\$)(\%)(\^)(\&)(\*)(\()(\))(\-)(\_)(\+)(\=) (\[)(\])(\{)(\})(\|)(\\)(\;)(\:)(\')(\")(\,)(\.)(\/) (\<)(\>)(\?)(\)]+/); 
     function vailId(pram)
            {
                if (pram==1){
                	 tempid=document.getElementById("module_id").value;
                    }
             
               tempid=tempid.replace(/(^\s*)|(\s*$)/g, ""); 
              if(tempid == null || tempid== undefined || tempid == '')
              {
                 alert("唯一标识符不能为空");
                 return;
              }
             if(patrn.exec(tempid))
              {
            	  alert("唯一标识符不能包含汉字");
            	  document.getElementById("module_id").value="";
      	        document.getElementById("module_id").focus();
      	        return;
             } 
              if(containSpecial.test(tempid))
              {
            	  alert("唯一标识符不能包含特殊字符");
            	  document.getElementById("module_id").value="";
      	        document.getElementById("module_id").focus();
      	        return;
             }    	         
	         
            }
     function ajaxRequest() {
    	    $.ajax({
    	      url: "${ctx}/plupmodule/findid?paramCode='"+tempid+"'",
    	      type: "POST",
    	      dataType: "json",
    	      async: false,
    	      success: function(data) {  
        	      var jspstate=data.model.idflag;
        	      if(jspstate==9999){
        	    	  alert("系统异常请联系管理员");
            	      }
        	      if(jspstate!=0 && jspstate!=9999){
        	    	    alert("移动应用标识已存在");
          	           document.getElementById("paramCode").value="";
          	            document.getElementById("paramCode").focus();
            	      }  
    	      },
    	      error: function() {    	        
    	        alert("error");
    	      }
    	    });
    	  }
     function save(){
          if(tempid == null || tempid== undefined || tempid == ''){
        	  alert("模块标识不能为空");
	          document.getElementById("module_id").value="";
	          document.getElementById("module_id").focus();
           }else{
          	   $.ajax({
        			type:'post',
        			url:'${ctx}/appFrameModule1/addModule',
        		    dataType: "json",
        		    data:$("#form").serialize(),
        		    async: false,
        			success:function(data){//返回json结果
            			var addstate=data.model.addflag;
            			if(addstate==0){
            				alert("新增失败");
            			}else{
            				alert("新增成功");
            				//window.location.href="${ctx}/appFrameModule1/appFrameModuleList1?appid="+data.model.appid+"&appname="+data.model.appname;
                			window.parent.location.reload(true);
            			}
        			}
        			
        		});
        	 
               }
     }
function addrow()
 {
     
	  var  html='<tr><td><input type="text"  class="form-control" id="param_code" name="param_code"/></td>'+
		'<td><input type="text"  class="form-control" id="param_name" name="param_name"/></td>'+
		'<td><input type="text"  class="form-control" id="param_default_value" name="param_default_value"/></td>'+			
		'<td><input type="text"  class="form-control" id="param_remarks" name="param_remarks"/></td></tr>';
	  $("table").append(html); 
	  
}

</script>
</head>
<body>
<div class="panel panel-default ">
   <div class="panel-heading">
      <h3 class="panel-title">
          模块创建
      </h3>
   </div>
   <div class="panel-body">
<form class="form-horizontal" role="form" id="form" name="form"  method="post">
                            <fieldset>
                        <legend>模块基本信息</legend>
                        <input class="form-control" id="param_code" name="param_code" type="hidden" value="${appid }"/>
                        <input class="form-control" id="param_name" name="param_name" type="hidden" value="${moduleid }"/>
                        <input class="form-control" id="param_remarks" name="param_remarks" type="hidden" value="${appname }"/>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="ds_host">模块标识</label>
                          <div class="col-xs-3">
                             <input class="form-control" id="module_id" name="module_id" type="text" onBlur="vailId(1)"/> 
                          </div>
                          <label class="col-xs-2 control-label" for="ds_name">模块名称</label>
                          <div class="col-xs-3">
                             <input class="form-control" id="module_name" name="module_name" type="text" />
                          </div>
                       </div>
                       <div class="form-group">
                          <label class="col-xs-2 control-label" for="ds_username">模块首页</label>
                          <div class="col-xs-3">
                             <input class="form-control" id="module_index_page_id" name="module_index_page_id" type="text" />
                          </div>
                          <label class="col-xs-2 control-label" for="ds_desc" style="display: none;">模块描述</label>
                          <div class="col-xs-3">
                             <input class="form-control" id="long_desc" name="long_desc" type="hidden" />
                          </div>
                       </div>                          
                    </fieldset>                     
 
                    <br></br>

					<div class="form-group">
						<div class="col-xs-5"></div>
						<div class="col-xs-5">
							<button type="button" class="btn btn-default" onclick="save()">&nbsp;&nbsp;确定&nbsp;&nbsp;</button>
							<button type="button" class="btn btn-default"  onclick="history.go(-1)">&nbsp;&nbsp;返回&nbsp;&nbsp;</button>
						</div>
					</div>
                    <br></br>
                </form>
	</div>
	</div>
</body>
</html>
